<html>
<head>
<script language="javascript">
function setcomponent() {
  if (window.opener) {
	var oEditor 	= window.opener.FCKeditorAPI.GetInstance('ta') ;
	var Name 	= document.new_component.Name.value;
	var Value 	= document.new_component.Value.value;
	var BackColor 	= document.new_component.BackColor.value;
	var FontFace 	= document.new_component.FontFace.value;
	var FontSize 	= document.new_component.FontSize.value;
	var ForeColor 	= document.new_component.ForeColor.value;
	var Width 	= document.new_component.Width.value;
	var Height 	= document.new_component.Height.value;

	var html="<input type='button' name='"+Name+"' id='"+Name+"' value='"+Value+"' ";

	/* proprieta */
	var style=0; //si puo dichiarare un solo style in un comando :(

	if (BackColor){
	    if (style==0){
		style=1;
		html=html + "style=\" ";
	    }
	    html=html + "background-color:"+BackColor+"; ";
	}
	if (FontFace){
	    if (style==0){
		style=1;
		html=html + "style=\" ";
	    }
	    html=html + "Font-Face:'"+FontFace+"'; ";
	}
	if (FontSize){
	    if (style==0){
		style=1;
		html=html + "style=\" ";
	    }
	    html=html + "Font-Size:"+FontSize+"; ";
	}
	if (ForeColor){
	    if (style==0){
		style=1;
		html=html + "style=\" ";
	    }
	    html=html + "color:"+ForeColor+"; ";
	}
	if (Width){
	    if (style==0){
		style=1;
		html=html + "style=\" ";
	    }
	    html=html + "width:"+Width+"; ";
	}
	if (Height){
	    if (style==0){
		style=1;
		html=html + "style=\" ";
	    }
	    html=html + "height:"+Height+"; ";
	}

	/* chiuse l'evebtuale style */
	if (style==1){
		style=0;
		html=html + " \"";
	}


	/* eventi */
	if (document.new_component.onFocus.checked)
	    html=html +"onFocus='"+Name+"_Focus(); ";
	if (document.new_component.onBlur.checked)
	    html=html +"onBlur='"+Name+"_Blur(); ";

	if (document.new_component.onSelect.checked)
	    html=html +"onSelect='"+Name+"_Selected(); ";
	if (document.new_component.onChange.checked)
	    html=html +"onChange='"+Name+"_Changed(); ";

	if (document.new_component.onClick.checked)
	    html=html +"onClick='"+Name+"_Click(); ";
	if (document.new_component.onDblClick.checked)
	    html=html +"onDblClick='"+Name+"_DblClick(); ";
	if (document.new_component.onMouseDown.checked)
	    html=html +"onMouseDown='"+Name+"_MouseDown(); ";
	if (document.new_component.onMouseUp.checked)
	    html=html +"onMouseUp='"+Name+"_MouseUp(); ";
	if (document.new_component.onMouseOver.checked)
	    html=html +"onMouseOver='"+Name+"_MouseOver(); ";
	if (document.new_component.onMouseMove.checked)
	    html=html +"onMouseMove='"+Name+"_MouseMove(); ";
	if (document.new_component.onMouseOut.checked)
	    html=html +"onMouseOut='"+Name+"_MouseOut(); ";
	if (document.new_component.onKeyPress.checked)
	    html=html +"onKeyPress='"+Name+"_KeyPress(); ";
	if (document.new_component.onKeyDown.checked)
	    html=html +"onKeyDown='"+Name+"_KeyDown(); ";
	if (document.new_component.onKeyUp.checked)
	    html=html +"onKeyUp='"+Name+"_KeyUp(); ";

	html=html +">\n";

	var code="";
	if (document.new_component.onFocus.checked)
	    code=code+"function "+Name+"_Focus(){\n}\n//---------------------------------------------------------------------------\n\n";
	if (document.new_component.onBlur.checked)
	    code=code+"function "+Name+"_Blur(){\n}\n//---------------------------------------------------------------------------\n\n";

	if (document.new_component.onSelect.checked)
	    code=code+"function "+Name+"_Selected(){\n}\n//---------------------------------------------------------------------------\n\n";
	if (document.new_component.onChange.checked)
	    code=code+"function "+Name+"_Changed(){\n}\n//---------------------------------------------------------------------------\n\n";

	if (document.new_component.onClick.checked)
	    code=code+"function "+Name+"_Click(){\n}\n//---------------------------------------------------------------------------\n\n";
	if (document.new_component.onDblClick.checked)
	    code=code+"function "+Name+"_DblClick(){\n}\n//---------------------------------------------------------------------------\n\n";
	if (document.new_component.onMouseDown.checked)
	    code=code+"function "+Name+"_MouseDown(){\n}\n//---------------------------------------------------------------------------\n\n";
	if (document.new_component.onMouseUp.checked)
	    code=code+"function "+Name+"_MouseUp(){\n}\n//---------------------------------------------------------------------------\n\n";
	if (document.new_component.onMouseOver.checked)
	    code=code+"function "+Name+"_MouseOver(){\n}\n//---------------------------------------------------------------------------\n\n";
	if (document.new_component.onMouseMove.checked)
	    code=code+"function "+Name+"_MouseMove(){\n}\n//---------------------------------------------------------------------------\n\n";
	if (document.new_component.onMouseOut.checked)
	    code=code+"function "+Name+"_MouseOut(){\n}\n//---------------------------------------------------------------------------\n\n";
	if (document.new_component.onKeyPress.checked)
	    code=code+"function "+Name+"_KeyPress(){\n}\n//---------------------------------------------------------------------------\n\n";
	if (document.new_component.onKeyDown.checked)
	    code=code+"function "+Name+"_KeyDown(){\n}\n//---------------------------------------------------------------------------\n\n";
	if (document.new_component.onKeyUp.checked)
	    code=code+"function "+Name+"_KeyUp(){\n}\n//---------------------------------------------------------------------------\n\n";

	alert(html);//debug
	oEditor.InsertHtml(html);
	window.opener.document.editor.codice.value=window.opener.document.editor.codice.value+code;
  }
  this.close();
}
// -------------------------------------------------------------------------------------------------------------- //

    function yuicolorpicker (name,theme){
	newWindow=window.open("../../yuicolorpicker/popup.php?name="+name+"&theme="+theme,"","' resizable=yes, width=400, height=250, status=0, toolbar=0 '");
	newWindow.creator=self;

    }
// -------------------------------------------------------------------------------------------------------------- //
</script>
<?php
?>

<link rel="stylesheet" type="text/css" href="../../../themes/<?=$_GET['theme'];?>/theme.css" media="screen, projection" title="theme" />
<title>button_properties</title>
</head>
<body>
<div class="table" style="width:230px;height:520;" >
<h3 class="bartitle">Button Properties</h3>

<form name="new_component" action="javascript:setcomponent();" >
<table class='class_table' >
<tr><td>Name		</td><td><input type="text" name="Name" value="button<?=rand(1,255);?>" /></td></tr>
<tr><td>Value		</td><td><input type="text" name="Value" value="button" /></td></tr>
<tr><td>BackColor	</td><td><input type="text" name="BackColor" value="" /> <input type='button' value=' ... ' onClick="yuicolorpicker('BackColor','<?=$_GET['theme'];?>');" /></td></tr>
<tr><td>Font-Face	</td>
    <td><select name="FontFace" >
	<option></option>
	<option>Arial</option>
	<option>Comic Sans MS</option>
	<option>Curier New</option>
	<option>Thaoma</option>
	<option>Times New Roman</option>
	<option>Verdana</option>
    </select></td>
</tr>
<tr><td>Font-Size	</td>
    <td><select name="FontSize" >
	<option></option>
	<option>xx-small</option>
	<option>x-small</option>
	<option>small</option>
	<option>medium</option>
	<option>large</option>
	<option>x-large</option>
	<option>xx-large</option>
    </select></td>
</tr>
<tr><td>ForeColor	</td><td><input type="text" name="ForeColor" value="" /> <input type='button' value=' ... ' onClick="yuicolorpicker('ForeColor','<?=$_GET['theme'];?>');" /></td></tr>
<tr><td>Width		</td><td><input type="text" name="Width" value="" /></td></tr>
<tr><td>Height		</td><td><input type="text" name="Height" value="" /></td></tr>
</table>
<hr />
<table class='class_table' >
<tr><td>onFocus 	</td><td><input type="checkbox" name="onFocus" /></td></tr>
<tr><td>onBlur	 	</td><td><input type="checkbox" name="onBlur" /></td></tr>

<tr><td>onSelect 	</td><td><input type="checkbox" name="onSelect" /></td></tr>
<tr><td>onChange 	</td><td><input type="checkbox" name="onChange" /></td></tr>

<tr><td>onClick 	</td><td><input type="checkbox" name="onClick" /></td></tr>
<tr><td>onDblClick 	</td><td><input type="checkbox" name="onDblClick" /></td></tr>
<tr><td>onMouseDown 	</td><td><input type="checkbox" name="onMouseDown" /></td></tr>
<tr><td>onMouseUp 	</td><td><input type="checkbox" name="onMouseUp" /></td></tr>
<tr><td>onMouseOver 	</td><td><input type="checkbox" name="onMouseOver" /></td></tr>
<tr><td>onMouseMove 	</td><td><input type="checkbox" name="onMouseMove" /></td></tr>
<tr><td>onMouseOut 	</td><td><input type="checkbox" name="onMouseOut" /></td></tr>
<tr><td>onKeyPress 	</td><td><input type="checkbox" name="onKeyPress" /></td></tr>
<tr><td>onKeyDown 	</td><td><input type="checkbox" name="onKeyDown" /></td></tr>
<tr><td>onKeyUp 	</td><td><input type="checkbox" name="onKeyUp" /></td></tr>
</table>
<hr />
<input type="submit" value="make button" />
</form>
</div>
</body>
</html>

